//
//  Stage.m
//  Memory5
//
//  Created by Jin Hu on 2010/08/09.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "MemoryStage.h"


@implementation MemoryStage
@synthesize currentStage;

-(id) init{
	if([super init]){
		currentStage=0;
	stages = [NSMutableArray arrayWithCapacity:8];
	[stages retain];
	[stages addObject:[UIImage imageNamed:@"stage_bay.jpg"]];
	[stages addObject:[UIImage imageNamed:@"stage_beach.jpg"]];
	[stages addObject:[UIImage imageNamed:@"stage_desert_city.jpg"]];
	[stages addObject:[UIImage imageNamed:@"stage_lake.jpg"]];
	[stages addObject:[UIImage imageNamed:@"stage_mill.jpg"]];
	[stages addObject:[UIImage imageNamed:@"stage_moutain.jpg"]];
	[stages addObject:[UIImage imageNamed:@"stage_valley.jpg"]];
	[stages addObject:[UIImage imageNamed:@"stage_vulcano.jpg"]];
	cards = [NSMutableArray arrayWithCapacity:24];
		[cards retain];
	}
	return self;
}
-(UIImage*) getBackground{
	return [stages objectAtIndex:currentStage];
}
-(NSMutableArray*)shuffelCards{
	[cards removeAllObjects];
	switch (currentStage) {
		
	case 0:
	default:
		[self initWithFaces];
		break;
	case 1:
		[self initWithPets];
		break;
	case 2:
		[self initWithArtifacts];
		break;
	case 3:
		[self initWithWapons];
		break;
	case 4:
		[self initWithFaces2];
		break;
	case 5:
		[self initWithPets2];
		break;
	case 6:
		[self initWithArtifacts2];
		break;
	case 7:
		[self initWithWapons2];
		break;
	}
	return cards;
}

-(void)initCards:(NSString*[24])names{
	for(int i=0;i<24;i++){
		int x =	i%4 * 80 + 10;
		int y = i/4 * 80 + 10;
		[cards addObject:[[Card alloc] initWithFrame:CGRectMake(x,y,58,58) front:names[i]]];
		
	}
	
}
	-(void)initWithFaces{
		NSString* dieren[24];
		dieren[0]=@"bat.png";
		dieren[1]=@"bird.png";
		dieren[2]=@"eden.png";
		dieren[3]=@"elf.png";
		dieren[4]=@"fish.png";
		dieren[5]=@"horse.png";
		dieren[6]=@"human.png";
		dieren[7]=@"iszu.png";
		dieren[8]=@"lizard.png";
		dieren[9]=@"orc.png";
		dieren[10]=@"yinoch.png";
		dieren[11]=@"basic.png";
		dieren[12]=@"basic.png";
		dieren[13]=@"yinoch.png";
		dieren[14]=@"orc.png";
		dieren[15]=@"lizard.png";
		dieren[16]=@"iszu.png";
		dieren[17]=@"human.png";
		dieren[18]=@"horse.png";
		dieren[19]=@"fish.png";
		dieren[20]=@"elf.png";
		dieren[21]=@"eden.png";
		dieren[22]=@"bird.png";
		dieren[23]=@"bat.png";
		
		[self initCards:dieren];
		
	}
	
	
	-(void)initWithPets {
		NSString* dieren[24];
		dieren[0]=@"pet_rat.png";
		dieren[1]=@"pet_rat.png";
		dieren[2]=@"pet_ox.png";
		dieren[3]=@"pet_ox.png";
		dieren[4]=@"pet_tiger.png";
		dieren[5]=@"pet_hare.png";
		dieren[6]=@"pet_tiger.png";
		dieren[7]=@"pet_dragon.png";
		dieren[8]=@"pet_snake.png";
		dieren[9]=@"pet_hare.png";
		dieren[10]=@"pet_horse.png";
		dieren[11]=@"pet_horse.png";
		dieren[12]=@"pet_goat.png";
		dieren[13]=@"pet_rooster.png";
		dieren[14]=@"pet_dragon.png";
		dieren[15]=@"pet_dog.png";
		dieren[16]=@"pet_pig.png";
		dieren[17]=@"pet_snake.png";
		dieren[18]=@"pet_pig.png";
		dieren[19]=@"pet_dog.png";
		dieren[20]=@"pet_goat.png";
		dieren[21]=@"pet_monkey.png";
		dieren[22]=@"pet_rooster.png";
		dieren[23]=@"pet_monkey.png";
		[self initCards:dieren];
	}
-(void)initWithArtifacts {
	NSString* dieren[24];
	dieren[0 ] =@"artifact_aquarius.png";
	dieren[1 ] =@"artifact_aquarius.png";
	dieren[2 ] =@"artifact_aries.png";
	dieren[3 ] =@"artifact_aries.png";
	dieren[4 ] =@"artifact_cancer.png";
	dieren[5 ] =@"artifact_cancer.png";
	dieren[6 ] =@"artifact_capricorn.png";
	dieren[7 ] =@"artifact_capricorn.png";
	dieren[8 ] =@"artifact_gemini.png";
	dieren[9 ] =@"artifact_gemini.png";
	dieren[10] =@"artifact_leo.png";
	dieren[11] =@"artifact_leo.png";
	dieren[12] =@"artifact_libra.png";
	dieren[13] =@"artifact_libra.png";
	dieren[14] =@"artifact_pisces.png";
	dieren[15] =@"artifact_pisces.png";
	dieren[16] =@"artifact_sagittarius.png";
	dieren[17] =@"artifact_sagittarius.png";
	dieren[18] =@"artifact_scorpio.png";
	dieren[19] =@"artifact_scorpio.png";
	dieren[20]=@"artifact_taurus.png";
	dieren[21]=@"artifact_taurus.png";
	dieren[22]=@"artifact_virgo.png";
	dieren[23]=@"artifact_virgo.png";
	
	[self initCards:dieren];
}
-(void)initWithWapons {
	NSString* dieren[24];
	dieren[0]=@"wapon_bow.png";
	dieren[1]=@"wapon_chain.png";
	dieren[2]=@"wapon_3.png";
	dieren[3]=@"wapon_schimitar.png";
	dieren[4]=@"wapon_7.png";
	dieren[5]=@"wapon_spear.png";
	dieren[6]=@"wapon_staff.png";
	dieren[7]=@"wapon_sword.png";
	dieren[8]=@"wapon_8.png";
	dieren[9]=@"wapon_9.png";
	dieren[10]=@"wapon_10.png";
	dieren[11]=@"wapon_11.png";
	dieren[12]=@"wapon_8.png";
	dieren[13]=@"wapon_9.png";
	dieren[14]=@"wapon_10.png";
	dieren[15]=@"wapon_11.png";
	dieren[16]=@"wapon_7.png";
	dieren[17]=@"wapon_spear.png";
	dieren[18]=@"wapon_staff.png";
	dieren[19]=@"wapon_sword.png";
	dieren[20]=@"wapon_bow.png";
	dieren[21]=@"wapon_chain.png";
	dieren[22]=@"wapon_3.png";
	dieren[23]=@"wapon_schimitar.png";
	[self initCards:dieren];
}
-(void)initWithFaces2{
	NSString* dieren[24];
	dieren[0 ]=@"bat.png";
	dieren[3 ]=@"bat.png";
	dieren[1 ]=@"bird.png";
	dieren[2 ]=@"bird.png";
	dieren[4 ]=@"eden.png";
	dieren[8 ]=@"eden.png";
	dieren[7 ]=@"elf.png";
	dieren[11]=@"elf.png";
	dieren[5 ]=@"fish.png";
	dieren[6 ]=@"fish.png";
	dieren[9 ]=@"horse.png";
	dieren[10]=@"horse.png";
	dieren[12]=@"human.png";
	dieren[20]=@"human.png";
	dieren[13]=@"iszu.png";
	dieren[21]=@"iszu.png";
	dieren[14]=@"lizard.png";
	dieren[22]=@"lizard.png";
	dieren[15]=@"orc.png";
	dieren[23]=@"orc.png";
	dieren[16]=@"yinoch.png";
	dieren[17]=@"yinoch.png";
	dieren[18]=@"basic.png";
	dieren[19]=@"basic.png";
	
	[self initCards:dieren];
	
}


-(void)initWithPets2 {
	NSString* dieren[24];
	dieren[0 ] =@"pet_rooster.png";
	dieren[1 ] =@"pet_dragon.png";
	dieren[2 ] =@"pet_dog.png";
	dieren[3 ] =@"pet_rooster.png";
	dieren[4 ] =@"pet_monkey.png";
	dieren[5 ] =@"pet_pig.png";
	dieren[6 ] =@"pet_dog.png";
	dieren[7 ] =@"pet_goat.png";
	dieren[8 ] =@"pet_monkey.png";
	dieren[9 ] =@"pet_hare.png";
	dieren[10] =@"pet_tiger.png";
	dieren[11] =@"pet_dragon.png";
	dieren[12] =@"pet_rat.png";
	dieren[13] =@"pet_ox.png";
	dieren[14] =@"pet_tiger.png";
	dieren[15] =@"pet_pig.png";
	dieren[16] =@"pet_snake.png";
	dieren[17] =@"pet_ox.png";
	dieren[18] =@"pet_horse.png";
	dieren[19] =@"pet_goat.png";
	dieren[20] =@"pet_snake.png";
	dieren[21] =@"pet_hare.png";
	dieren[22] =@"pet_horse.png";
	dieren[23] =@"pet_rat.png";
	[self initCards:dieren];
}
-(void)initWithArtifacts2 {
	NSString* dieren[24];
	dieren[0 ] =@"artifact_aquarius.png";
	dieren[1 ] =@"artifact_sagittarius.png";
	dieren[2 ] =@"artifact_scorpio.png";
	dieren[3 ] =@"artifact_taurus.png";
	dieren[4 ] =@"artifact_virgo.png";
	dieren[5 ] =@"artifact_libra.png";
	dieren[6 ] =@"artifact_leo.png";
	dieren[7 ] =@"artifact_scorpio.png";
	dieren[8 ] =@"artifact_sagittarius.png";
	dieren[9 ] =@"artifact_pisces.png";
	dieren[10] =@"artifact_gemini.png";
	dieren[11] =@"artifact_leo.png";
	dieren[12] =@"artifact_libra.png";
	dieren[13] =@"artifact_gemini.png";
	dieren[14] =@"artifact_capricorn.png";
	dieren[15] =@"artifact_cancer.png";
	dieren[16] =@"artifact_aries.png";
	dieren[17] =@"artifact_cancer.png";
	dieren[18] =@"artifact_capricorn.png";
	dieren[19] =@"artifact_virgo.png";
	dieren[20] =@"artifact_taurus.png";
	dieren[21] =@"artifact_pisces.png";
	dieren[22] =@"artifact_aries.png";
	dieren[23] =@"artifact_aquarius.png";
	[self initCards:dieren];
}
-(void)initWithWapons2 {
	NSString* dieren[24];
	dieren[0 ] =@"wapon_staff.png";
	dieren[1 ] =@"wapon_sword.png";
	dieren[2 ] =@"wapon_bow.png";
	dieren[3 ] =@"wapon_chain.png";
	dieren[4 ] =@"wapon_3.png";
	dieren[5 ] =@"wapon_7.png";
	dieren[6 ] =@"wapon_spear.png";
	dieren[7 ] =@"wapon_staff.png";
	dieren[8 ] =@"wapon_sword.png";
	dieren[9 ] =@"wapon_8.png";
	dieren[10] =@"wapon_9.png";
	dieren[11] =@"wapon_10.png";
	dieren[12] =@"wapon_bow.png";
	dieren[13] =@"wapon_chain.png";
	dieren[14] =@"wapon_3.png";
	dieren[15] =@"wapon_5.png";
	dieren[16] =@"wapon_spear.png";
	dieren[17] =@"wapon_11.png";
	dieren[18] =@"wapon_8.png";
	dieren[19] =@"wapon_9.png";
	dieren[20] =@"wapon_10.png";
	dieren[21] =@"wapon_11.png";
	dieren[22] =@"wapon_5.png";
	dieren[23] =@"wapon_7.png";
	[self initCards:dieren];
}

@end
